package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.FaultManageMapper;
import com.gc.business.domain.FaultManage;
import com.gc.business.service.IFaultManageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 故障管理 服务层实现
 * 
 * @author 刘锦腾
 * @date 2020-12-08
 */
@Slf4j
@Service
public class FaultManageServiceImpl extends ServiceImpl<FaultManageMapper, FaultManage> implements IFaultManageService {

    @Override
    public List<FaultManage> list(FaultManage faultManage){
        LambdaQueryWrapper<FaultManage> wrapper = new LambdaQueryWrapper<>();
        if(faultManage != null){
            if(StringUtils.isNotEmpty(faultManage.getFaultId())){
                wrapper.eq(FaultManage::getFaultId, faultManage.getFaultId());
            }
            if(StringUtils.isNotEmpty(faultManage.getBrandId())){
                wrapper.eq(FaultManage::getBrandId, faultManage.getBrandId());
            }
            if(StringUtils.isNotEmpty(faultManage.getModelId())){
                wrapper.eq(FaultManage::getModelId, faultManage.getModelId());
            }
            if (StringUtils.isNotEmpty(faultManage.getModelIds())){
                wrapper.like(FaultManage::getModelIds, faultManage.getModelIds());
            }
            if(StringUtils.isNotEmpty(faultManage.getBrandName())){
                wrapper.like(FaultManage::getBrandName, faultManage.getBrandName());
            }
            if(StringUtils.isNotEmpty(faultManage.getModelName())){
                wrapper.like(FaultManage::getModelName, faultManage.getModelName());
            }
            if(StringUtils.isNotEmpty(faultManage.getFaultCode())){
                wrapper.eq(FaultManage::getFaultCode, faultManage.getFaultCode());
            }
            if(StringUtils.isNotEmpty(faultManage.getFaultDescribe())){
                wrapper.like(FaultManage::getFaultDescribe, faultManage.getFaultDescribe());
            }
            if(StringUtils.isNotEmpty(faultManage.getPossibleCauses())){
                wrapper.like(FaultManage::getPossibleCauses, faultManage.getPossibleCauses());
            }
            if(StringUtils.isNotEmpty(faultManage.getDefectiveElement())){
                wrapper.like(FaultManage::getDefectiveElement, faultManage.getDefectiveElement());
            }
            if(StringUtils.isNotEmpty(faultManage.getElevatorStatus())){
                wrapper.like(FaultManage::getElevatorStatus, faultManage.getElevatorStatus());
            }
            if(StringUtils.isNotEmpty(faultManage.getRecovery())){
                wrapper.like(FaultManage::getRecovery, faultManage.getRecovery());
            }
            if(StringUtils.isNotEmpty(faultManage.getExperiment())){
                wrapper.like(FaultManage::getExperiment, faultManage.getExperiment());
            }
            if(StringUtils.isNotEmpty(faultManage.getCreateBy())){
                wrapper.like(FaultManage::getCreateBy, faultManage.getCreateBy());
            }
            if(StringUtils.isNotEmpty(faultManage.getCreateTime())){
                wrapper.eq(FaultManage::getCreateTime, faultManage.getCreateTime());
            }
            if(StringUtils.isNotEmpty(faultManage.getUpdateBy())){
                wrapper.like(FaultManage::getUpdateBy, faultManage.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(faultManage.getUpdateTime())){
                wrapper.eq(FaultManage::getUpdateTime, faultManage.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(faultManage.getRemark())){
                wrapper.eq(FaultManage::getRemark, faultManage.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<FaultManage> selectFaultCodeList(Long brandId, Long modelId, String faultCode) {
        return baseMapper.selectFaultCodeList(brandId,modelId,faultCode);
    }
}
